package com.example.springboot_08_thymeleaf.controller;


import com.example.springboot_08_thymeleaf.entity.Comment;
import com.example.springboot_08_thymeleaf.mapper.commentMapper;
import com.example.springboot_08_thymeleaf.service.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class indexController {
    @Autowired
    private service s;
    @Autowired
    private commentMapper c;
    @GetMapping("/index")
    public String index(Model model){
        model.addAttribute("title","传递的Title");
        List<Comment> comment = c.findAll();
        model.addAttribute("comments",comment);
        return "index";

    }

}
